package com.fsnbigdata.repository;
import com.fsnbigdata.domain.AnimalConservationLocation;
import org.springframework.data.jpa.repository.Query;
import org.springframework.roo.addon.layers.repository.jpa.annotations.RooJpaRepository;
import com.fsnbigdata.domain.AnimalConservation;
import io.springlets.data.jpa.repository.DetachableJpaRepository;
import java.util.List;
import org.springframework.transaction.annotation.Transactional;

/**
 * = AnimalConservationLocationRepository
 *
 * TODO Auto-generated class documentation
 *
 */
@RooJpaRepository(entity = AnimalConservationLocation.class)
@Transactional(readOnly = true)
public interface AnimalConservationLocationRepository extends DetachableJpaRepository<AnimalConservationLocation, Long>, AnimalConservationLocationRepositoryCustom {

    /**
     * TODO Auto-generated method documentation
     *
     * @param animalConservation
     * @return Long
     */
    public abstract long countByAnimalConservation(AnimalConservation animalConservation);

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return AnimalConservationLocation
     */
    public abstract AnimalConservationLocation findOne(Long id);

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return List
     */
    public abstract List<AnimalConservationLocation> findAll(Iterable<Long> id);

    /**
     * TODO Auto-generated method documentation
     *
     * @param animalConservationLocation
     * @return AnimalConservationLocation
     */
    public abstract AnimalConservationLocation save(AnimalConservationLocation animalConservationLocation);

    @Query(value = "select animal_conservation_id from animal_conservation_location where if(?1 !='',preserve_location like concat('%',?1,'%'),1=1) GROUP BY animal_conservation_id",nativeQuery = true)
    public List<Long> getIds(String preserveLocation);

    @Query(value = "select preserve_location from animal_conservation_location where animal_conservation_id =?1 GROUP BY preserve_location",nativeQuery = true)
    public List<String> getLocation(String id);
}
